using System;
using System.Collections;
using System.Reflection;
using flickr.api.communication;

namespace flickr.api
{
	public class Flickr
	{
	    public static FlickrConnection Connection;
	    private static Hashtable _flickrObjects = new Hashtable();

        public static string ApiKey;
        public static string SharedSecret;
        public static string ApiToken;
	    
	    private static object Instance(Type type)
	    {
	        if (Connection == null)
	        {
	            Connection = new FlickrConnection(ApiKey, SharedSecret, ApiToken);
	        }
	        if (_flickrObjects[type] == null)
	        {
                ConstructorInfo info = type.GetConstructor(new Type[]{ typeof(FlickrConnection) });
	            _flickrObjects[type] = info.Invoke(new object[] { Connection });
	        }
            return _flickrObjects[type];
	    }

	    public static Auth Auth
	    {
            get { return (Auth)Instance(typeof(Auth)); }
	    }
	    
	    public static Blogs Blogs
	    {
            get { return (Blogs)Instance(typeof(Blogs)); }
	    }
	    
	    public static Contacts Contacts
	    {
            get { return (Contacts)Instance(typeof(Contacts)); }
	    }
	    
	    public static Favorites Favorites
	    {
            get { return (Favorites)Instance(typeof(Favorites)); }
	    }

        public static Groups Groups
        {
            get { return (Groups)Instance(typeof(Groups)); }
        }
//
//        public static Comments Comments
//        {
//            get { return (Comments)Instance(typeof(Comments)); }
//        }
	    
	    public static People People
	    {
            get { return (People)Instance(typeof(People)); }
	    }

	    public static Photos Photos
        {
            get { return (Photos)Instance(typeof(Photos)); }
        }

        public static Photosets Photosets
        {
            get { return (Photosets)Instance(typeof(Photosets)); }
        }

        public static Tags Tags
        {
            get { return (Tags)Instance(typeof(Tags)); }
        }
	    
        public static Urls Urls
        {
            get { return (Urls)Instance(typeof(Urls)); }
        }	    
    }
}
